import {Express} from 'express'
import express = require("express");
import usersRouter from "./routes/users";
import indexRouter from "./routes/index";
import path from "path";
import cookieParser from "cookie-parser";
import logger from "morgan";

const app: Express = express();

//Application-level middleware
app.use(logger('dev'));
app.use(express.json());
app.use((req, res, next) => {
    console.log('Time:', Date.now());
    next()
});
app.use(express.urlencoded({extended: false}));
app.use(cookieParser());
app.use(express.static(path.join(__dirname, 'public')));

app.use('/', indexRouter);
app.use('/users', usersRouter);

export default app;